/*
 ============================================================================
 Name		: TradeBlockQueryTransferTurnover.h
 Author	  : spring xu
 Version	 : 1.0
 Copyright   : Your copyright notice
 Description : CTradeFundCode declaration
 ============================================================================
 */

#ifndef TRADEFUNDQUERYCODE_H
#define TRADEFUNDQUERYCODE_H

// INCLUDES
#include "TradeBlock.h"
#include "Control.h"
#include "TableWidget.h"
#include "TradeBlockNetwork.h"

// CLASS DECLARATION

class CTradeFundQueryCode: public CTradeBlock, public MWidgetObserver, public MPushButtonObserver//, public MReqObserver
{
public:
    ~CTradeFundQueryCode();

    static CTradeFundQueryCode* NewL(CBaseBlock* bsBack);

    static CTradeFundQueryCode* NewLC(CBaseBlock* bsBack);

private:
    CTradeFundQueryCode(CBaseBlock* bsBack);

    void ConstructL();

public:
    void OnDraw(CFbsBitGc& g) const;

    void OnKeyDown(TInt keyCode);
    
    void OnMouseDown(const TPoint& aPt);
    
    void OnMouseMove(const TPoint& aPt);

    void OnMouseUp(const TPoint& aPt);

    void SizeChanged();    
    
    void ChangeFocus(TBool aFoucs, const TInt& keyCode);
    
    void BeforeBack();
    
    //void InitData();
    void InitNetworkData();
    
private:
    void CreateControls();

	void LayoutControls();
    
protected:
    void AddTabs();

    void BeforeDraw(CFbsBitGc& g) const;
    
private:
    void CreateFundCompanyCodeTable();
    void CreateFundCodeTable();
    
    TInt AppendNetworkData(p_fundCompany_info_t pArray);
    TInt AppendNetworkData(p_openfund_info_t pArray);
    void QueryFundCode(TInt nFundCompanyArrayIndex);
public:
    // from MWidgetObserver
    void UpdateScreen();
    
    void SelectOneRow(TInt aRowIndex);
    
    void LoseFocus(const TInt& keycode);
    
public: //MPushButtonObserver
    void PushButtonClicked();
    
public:
	TBool ProcessTradeNetworkMsg(TInt nError, TAny* p, const TDesC8& aBodyData);
	//TBool UpdateTradeNetwork(TInt nProgress);
	
private:
	enum TNetworkStatus
	{
		ENetworkStatus_None,
		ENetworkStatus_ReqFundCompanyCode,
		ENetworkStatus_ReqFundCode,
		ENetworkStatus_Response
	};
	enum TQueryType
	{
		EQueryType_FundCompanyCode,
		EQueryType_FundCode,
	};
	
private:
    CTableWidget* iTable;
    
    //CPushButton* iButtonCancel;
    CPushButton* iButtonMore;
    
    TInt	iNumberOfElement;
	TBool	iCanReq;
    TInt	iFocusControl;
    TInt	iNetworkStatus;
    TInt	iQueryType;
    
    TInt 	iFundCompanyArrayIndex;
};

#endif // TRADEBLOCKQUERYFUNDS_H
